package com.songlanyun.common.enums;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 作品相关枚举
 */
public class OpusConstant {

    /**
     * 作品类型（0图文，1视频）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum OpusType implements IntegerEnum<Integer> {

        IMAGE_TEXT(0, "图文"),//图文

        VIDEO(1, "视频"),//视频
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        OpusType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static OpusConstant.OpusType getByCode(int code) {
            for (OpusConstant.OpusType value : OpusConstant.OpusType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 发布者类型 0平台，1会员，2商家
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum PublisherType implements IntegerEnum<Integer> {

        PLATFORM(0, "平台"),//平台

        Member(1, "会员"),//会员

        SHOP(2, "商家"),//会员
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        PublisherType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static OpusConstant.PublisherType getByCode(int code) {
            for (OpusConstant.PublisherType value : OpusConstant.PublisherType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 审核状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum VerifyStatus implements IntegerEnum<Integer> {
        WAIT(0, "待审核"),
        YES(1, "通过"),
        NO(2, "不通过");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        VerifyStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static GoodsConstant.VerifyStatus getByCode(int code) {
            for (GoodsConstant.VerifyStatus value : GoodsConstant.VerifyStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 类型
     * 0 opus 作品，
     * 1 article 文章，
     * 2 common_goods 普通商品
     * 3 service_goods 服务商品
     * 4 seckill_goods秒杀商品
     * 5 group_buy_goods拼团商品
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ModelType implements IntegerEnum<Integer> {

        OPUS(0, "作品"),

        ARTICLE(1, "文章"),

        COMMON_GOODS(2, "普通商品"),

        SERVICE_GOODS(3, "服务商品"),

        SECKILL_GOODS(4, "秒杀商品"),

        GROUP_BUY_GOODS(5, "拼团商品"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ModelType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ModelType getByCode(int code) {
            for (ModelType value : ModelType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * BBS类型：
     * 0：浏览
     * 1：点赞
     * 2：分享
     * 3：评论
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum BbsType implements IntegerEnum<Integer> {

        BROWSE(0, "浏览"),
        LIKE(1, "点赞"),
        SHARE(2, "分享"),
        COMMENT(3, "评论"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        BbsType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static BbsType getByCode(int code) {
            for (BbsType value : BbsType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


}
